import request from '../utils/request.js';

//  获取文章
export const postArticlei = (url, page, count) => {
  return request({
    method: 'post',
    url: url,
    data: { pageNum: page, pageSize: count },
  });
};
//  最新文章
export const postNewArticle = (page, count) => {
  return request({
    method: 'post',
    url: '/es/newestArticle',
    data: { pageNum: page, pageSize: count },
  });
};

//  根据 id 查询 文章详情
export const postArtDetails = id => {
  return request({
    method: 'post',
    url: `/es/findByIdArticle/${id}`,
  });
};

// 上传图片
export const richTextImgUpload = formData => {
  return request({
    method: 'post',
    url: '/upload/upload',
    data: { img: formData },
  });
};

// 获取原文章点赞信息
export const likeArticle = (articleId, token) => {
  return request({
    method: 'post',
    url: `/es/articleLikesState/${articleId}`,
    headers: { Authorization: token },
  });
};

// 点击后 点赞按钮后的 点赞状态
export const likeArticleState = (articleId, token, state) => {
  return request({
    method: 'post',
    url: '/es/articleLikes',
    headers: { Authorization: token },
    data: {
      articleId: articleId,
      whetherAttention: state,
    },
  });
};
